package top.v5it.japi.ddd.core.config;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 自动注入
 *
 * @author zhanpu
 * @date 2023/3/9
 */
@ComponentScan("top.v5it.japi.ddd.core")
@MapperScan(basePackages = {"top.v5it.japi.ddd.core.dao.impl.mybatis"})
public class JapiDddAutoConfiguration {

    @Bean
    public WebMvcConfigurer webMvcConfigurer(HandlerInterceptor cleanInterceptor, HandlerInterceptor traceInterceptor) {
        return new WebMvcConfigurer() {
            @Override
            public void addInterceptors(InterceptorRegistry registry) {
                registry.addInterceptor(cleanInterceptor);
                registry.addInterceptor(traceInterceptor);
            }
        };
    }
}
